/*
Disclaimer of Warranty: THE PACKAGE IS PROVIDED
BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS'
AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT
ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW.
UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF
THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


(c) Copyright 2013 Edward Principe
All Rights Reserved

*/
#ifndef TYPEMACROS_H
#define TYPEMACROS_H

#include <Windows.h>
#include <tchar.h>
#include <string>

using namespace std;

//////////////////////////////////////////////////////////////
// Bit size of types
//////////////////////////////////////////////////////////////
#define BIT_BYTE 8
#define BIT_CHAR 16
#define BIT_BOOL 8
#define BIT_SHORT 16
#define BIT_INT 32
#define BIT_LONG_INT 64
#define BIT_FLOAT 32
#define BIT_DOUBLE 64
#define BIT_LONG_DOUBLE 128

//////////////////////////////////////////////////////////
// Conversion macros
/////////////////////////////////////////////////////////
#define BIT_TO_BYTE(x) (x) / BIT_BYTE
#define BYTE_TO_BIT(x) (x) * BIT_BYTE;

//////////////////////////////////////////////////////////////
// Types
//////////////////////////////////////////////////////////////
typedef char VAR_BYTE;
typedef wchar_t VAR_CHAR;
typedef char VAR_BOOL;
typedef __int16 VAR_SHORT;
typedef __int32 VAR_INT;
typedef __int64 VAR_LONG;
typedef float VAR_FLOAT;
typedef double VAR_DOUBLE;
typedef long double VAR_LONG_DOUBLE;
typedef wstring VAR_STRING;

typedef VAR_SHORT VAR_HALF_WORD;
typedef VAR_INT VAR_WORD;
typedef VAR_LONG VAR_DOUBLE_WORD;

typedef void VAR_VOID;

typedef __int16 VAR_TOKEN;

//////////////////////////////////////////////////////////////
// VarType: Type of variable
/////////////////////////////////////////////////////////////
enum VarType
{
	VAR_TYPE_BYTE,
	VAR_TYPE_CHAR,
	VAR_TYPE_BOOL,
	VAR_TYPE_SHORT,
	VAR_TYPE_INT,
	VAR_TYPE_LONG,
	VAR_TYPE_FLOAT,
	VAR_TYPE_DOUBLE,
	VAR_TYPE_LONG_DOUBLE,
	VAR_TYPE_STRING,
	VAR_TYPE_WORD,
	VAR_TYPE_DOUBLE_WORD,
	VAR_TYPE_VOID,
	VAR_TYPE_TOKEN,
	VAR_TYPE_STRUCT, // A structure
	VAR_TYPE_NONE // No type
};

///////////////////////////////////////////////////////////
// VarData: Data union
//////////////////////////////////////////////////////////
union VarData
{
	VAR_BYTE byte_data;
	VAR_WORD word_data;
	VAR_DOUBLE_WORD double_word_data;

	VAR_BOOL bool_data;
	VAR_CHAR char_data;
	VAR_SHORT short_data;
	VAR_LONG long_data;

	VAR_FLOAT float_data;
	VAR_DOUBLE double_data;
	VAR_LONG_DOUBLE long_double_data;

	VAR_CHAR *string_data;

	VAR_VOID *void_data;

	VAR_TOKEN token; // A token

};

/////////////////////////////////////////////////////////////////////////////////////
// Tokens
/////////////////////////////////////////////////////////////////////////////////////
#define TTOK_MOVE 1
#define TTOK_ADD 2
#define TTOK_SUB 3
#define TTOK_MUL 4
#define TTOK_DIV 5
#define TTOK_MOD 6
#define TTOK_CMP 7
#define TTOK_JE 8
#define TTOK_JNE 9
#define TTOK_JG 10
#define TTOK_JL 12
#define TTOK_JUMP 13
#define TTOK_GOTO TTOK_JUMP
#define TTOK_COPY_STRING 14
#define TTOK_LINE 15
#define TTOK_NONE 16
#define TTOK_NO_COMMAND TTOK_NONE

//////////////////////////////////////////////////////////////////////////////////
// Some basic defines
//////////////////////////////////////////////////////////////////////////////////
#define VASM_TRUE 1
#define VASM_FALSE 0
#define VASM_NULL 0
#endif